package wondersgroup.hsswidget.scroll;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ScrollView;

/**
 * <b>Project:</b> MyView<br>
 * <b>Create Date:</b> 2016/10/20 0020<br>
 * <b>Author:</b> huang saisai <br>
 * <b>Description:</b> <br>
 */
public class DiscrollView extends ScrollView {
    DiscrollLinearLayout mContent;
    int mWidth, mHeight;
    public DiscrollView(Context context) {
        super(context);
    }

    public DiscrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public DiscrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        View content = getChildAt(0);
        mContent = (DiscrollLinearLayout) content;
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        mWidth = w;
        mHeight = h;
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);

        for (int i=0,size = mContent.getChildCount(); i < size ; i ++){
            View child = mContent.getChildAt(i);
            if (child instanceof  DiscrollInterface){
                DiscrollInterface discrollInterface = (DiscrollInterface) child;
                int[] position = new int[2];
                child.getLocationOnScreen(position);
//                if (position[1] - mHeight){
//
//                }
//                float ratio = 0;//0~1
//                viewGroup.onDiscroll(ratio);
            }else {
                continue;
            }
        }
    }
}
